<template>
	<view class="goods-item">
	  <!-- 商品项 左侧的图片 -->
	  <view class="goods-item-left">
	    <image :src="item.goods_small_logo || defaultPic"></image>
	  </view>
	  <!-- 商品项右侧 -->
	  <view class="goods-item-right">
	    <!-- 商品名称 -->
	    <view class="goods-name">{{item.goods_name}}</view>
	    <!-- 商品价格 -->
	    <view class="goods-info-box">
        <!-- 使用过滤器  为价格保留两位小数 -->
	      <text>￥{{item.goods_price | fixNum}}</text>
	    </view>
	  </view>
	</view>
</template>

<script>
	export default {
    props: {
      item: {
        type: Object,
        default: {}
      }
    },
		data() {
			return {
				// 默认的空图片
				defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png'
			};
		},
    
    // 过滤器
    filters: {
      fixNum(value){
        return value.toFixed(2)
      }
    }
	}
</script>

<style lang="scss">
  .goods-item{
    display: flex;
    padding: 8px 5px;
    border-bottom: 1px solid #efefef;
    .goods-item-left {
      image {
        display: block;
        margin: 0 5px;
        width: 100px;
        height: 100px;
      }
    }
    .goods-item-right {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .goods-name {
        font-size: 13px;
      }
      .goods-info-box {
        font-size: 16px;
        color: #C00000;
      }
    }
  }
</style>
